# 基础镜像：NVIDIA CUDA 12.4 开发版 (Ubuntu 22.04)
FROM nvidia/cuda:12.4.0-devel-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive

# 安装工具 & Python3.12
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        software-properties-common \
        curl \
        ca-certificates \
        gnupg2 \
        vim-gtk3 \
        && \
    add-apt-repository ppa:deadsnakes/ppa -y && \
    apt-get update && \
    apt-get install -y --no-install-recommends \
        python3.12 \
        python3.12-venv \
        && \
    curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12 && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# 设置 python3 和 pip3 指向 Python3.12
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 2 && \
    update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip3 2 && \
    update-alternatives --install /usr/bin/pip3 pip3 /usr/local/bin/pip3 2

# ✅ 配置 pip 使用国内源（清华镜像）
RUN python3 -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

# 验证 Python & pip
RUN python3 --version && pip3 --version

# 工作目录
WORKDIR /workspace

# 默认进入 shell
CMD ["bash"]

